package com.ruoyi.system.domain.dto;

import lombok.Data;

import javax.validation.constraints.NotEmpty;

/**
 * 验证码
 *
 * @author Administrator
 * @date 2021/01/13
 */
@Data
public class CaptchaDTO {
    @NotEmpty(message = "手机号码不能为空")
    private String phone;

    @NotEmpty(message = "验证码业务类型不能为空")
    private String codeType;

    private Integer code;

    private static final String SMS_CODE ="sms_code:";

    /**
     * 验证码业务类型
     * 0登录短信 1重置密码 2微信扫码登录验证码 3手机绑定 4账号注销
     *
     * @param type 类型
     * @return {@link String}
     */
    public static String codeType(String type, String phone) {
        String typeName;
        switch (type) {
            case "0":
                typeName = SMS_CODE + "login_code:" + phone;
                break;
            case "1":
                typeName = SMS_CODE + "reset_code:" + phone;
                break;
            case "2":
                typeName = SMS_CODE + "wechat_account_code:" + phone;
                break;
            case "3":
                typeName = SMS_CODE + "mobile_phone_bind:" + phone;
                break;
            case "4":
                typeName = SMS_CODE + "remove_account:" + phone;
                break;
            default:
                typeName = SMS_CODE;
                break;
        }
        return typeName;
    }
}
